package com.axjy.web;

import com.axjy.pojo.Systemconfig;
import com.axjy.service.ConfigService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by asus on 2018/3/10.
 */
@RestController
@RequestMapping("/sys/config")
public class ConfigHandler {
    @Resource
    private ConfigService configService;

    @GetMapping("/search")
    public List<Systemconfig> search(){
        return configService.search();
    }

    @PostMapping("/updateStatus")
    public String updateStatus(Integer isStart, String configCode, String valueName){
        String msg=null;
        try{
            configService.updateStatus(isStart, configCode, valueName);
            msg="1";
        }catch (RuntimeException ex){
            msg="0";
        }
        return msg;
    }

}
